import { ref } from "vue";

export function useColumns() {
  const editMap = ref({});
  const columns: TableColumnList = [
    {
      label: "姓名",
      prop: "data1",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-input v-model={row.data1} />
          ) : (
            <p>{row.data1}</p>
          )}
        </>
      )
    },
    {
      label: "爱好",
      prop: "data2",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-input v-model={row.data2} />
          ) : (
            <p>{row.data2}</p>
          )}
        </>
      )
    },
    {
      label: "操作",
      fixed: "right",
      slot: "operation"
    }
  ];
  return {
    editMap,
    columns,
  };
}
